package cn.panda.edu.service.impl;

import cn.panda.edu.dao.JudgeMapper;
import cn.panda.edu.model.Judge;
import cn.panda.edu.service.JudgeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 
 * 类描述：  JudgeService接口的实现类
 * @author: 张春雷
 * @date： 2018-01-18 上午11:06:55
 */
@Service
public class JudgeServiceImpl implements JudgeService {

	@Resource
	private JudgeMapper judgeMapper;
	@Override
	public PageInfo<Judge> listJudgeByCourseId(Integer courseId, Integer pageIndex, Integer pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageIndex, pageSize);
		List<Judge> list = judgeMapper.listJudgeByCourseId(courseId);
		PageInfo<Judge> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	@Override
	public PageInfo<Judge> listJudgeBySectionTestId(Integer sectionTestId, Integer pageIndex, Integer pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageIndex, pageSize);
		List<Judge> list = judgeMapper.listJudgeBySectionTestId(sectionTestId);
		PageInfo<Judge> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	/**
	 * 根据题目ID查询
	 */
	@Override
	public Judge selectByPrimaryKey(Integer judgeId) {
		// TODO Auto-generated method stub
		return judgeMapper.selectByPrimaryKey(judgeId);
	}
	/**
	 * 动态更新判断题
	 */
	@Override
	public int updateByPrimaryKeySelective(Judge record) {
		// TODO Auto-generated method stub
		return judgeMapper.updateByPrimaryKeySelective(record);
	}
	/**
	 * 根据题目编号删除
	 */
	@Override
	public int deleteByPrimaryKey(Integer judgeId) {
		// TODO Auto-generated method stub
		return judgeMapper.deleteByPrimaryKey(judgeId);
	}
	/**
	 * 动态添加判断题
	 */
	@Override
	public int insertSelective(Judge record) {
		// TODO Auto-generated method stub
		return judgeMapper.insertSelective(record);
	}

}
